package com.qf.config;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.sql.SQLOutput;

/**
 * 自定义的切面类
 */
@Aspect
@Component
public class MyAspect {
    //切点表达式
    @Pointcut("execution(* *.*.service.impl.*.*(..))")
    public void pt1(){}
    /**
     * 环绕通知
     */
    @Around("pt1()")
    public Object myround(ProceedingJoinPoint proceedingJoinPoint){
        Object obj = null;

        try {
            System.out.println("前置通知");
            //执行业务方法
            obj = proceedingJoinPoint.proceed();
            System.out.println("后置通知");
            return obj;
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }

        return null;
    }
}
